home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 4.6 KB | 170 lines | [TEXT/KAHL] |
- // ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- // • Program: FrameAnim
- // • File: Setup.c
- // •
- // • Copyright © 1993 by Scott B. Steinman, O.D., Ph.D. All Rights Reserved.
- // ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
-
- #include <Packages.h>
- #include "FrameAnim.h"
-
- // • ------------------ External Globals ----------------------------------
-
- extern CWindowPtr gMainWindow; // • From Main.c file
- extern GWorldPtr gFrames[]; // • From Main.c file
- extern GDHandle gDevice; // • From Main.c file
- extern PaletteHandle gPalette; // • From Main.c file
- extern CTabHandle gCTable; // • From Main.c file
- extern Handle gMenuBar; // • From Main.c file
- extern Settings gSettings; // • From Main.c file
- extern Rect gGlobBounds; // • From Animation.c file
-
- // •------------------- Static Variables ----------------------------------
-
- CWindowRecord sMainRecord; // • Storage for window info
-
- // •------------------- Initialize Toolbox Managers -----------------------
-
- void
- InitManagers( void )
- // •
- // • Used to initialize Toolbox managers
- {
- short i;
-
-
- MaxApplZone();
-
- InitGraf( &thePort ); // • Initialize QuickDraw.
-
- for (i = 0; i < 8; i++)
- MoreMasters(); // • Extra pointer blocks at bottom of heap
-
- InitFonts();
- FlushEvents( everyEvent, kRemoveAllEvents ); // • Clear out event queue
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( NullPointer );
- InitAllPacks();
- }
-
- // • ------------------ Get Number of Monitors ----------------------------
-
- void
- GetNumMonitors( void )
- // •
- // • Finds number of monitors present in system.
- {
- GDHandle device = NullHandle;
-
- device = GetMainDevice();
- device = GetNextDevice( device );
- if (device == NullHandle) {
- gSettings.numMonitors = 1;
- gSettings.displayMonitor = kMain;
- }
- else
- gSettings.numMonitors = 2;
- }
-
- // • ------------------ Prepare Animation Display Window ------------------
-
- void
- SetUpWindows( void )
- // •
- // • Creates main output window
- {
- Rect boundingBox;
- long refVal; // • Reference value used by window manager
- short typeOfW = 4; // • Window type = noGrow document
- Boolean visible = true, // • Window is shown
- goAway = false; // • Window has no close box
-
- if (gSettings.numMonitors == 1) {
- HLock( (Handle) GrayRgn ); // • If only one monitor, use its bounding box
- boundingBox = (**GrayRgn).rgnBBox;
- HUnlock( (Handle) GrayRgn );
- }
- else {
- HLock( (Handle) gDevice );
- boundingBox = (**gDevice).gdRect; // • Get device's bounding box
- HUnlock( (Handle) gDevice );
- }
-
- gMainWindow = (CWindowPtr) NewCWindow( (WindowRecord *) &sMainRecord,
- &boundingBox, "\pFrame Animation", visible, typeOfW, NullPointer, goAway, refVal );
- if (gMainWindow == NullPointer)
- ErrorHandler( kNoWindMsg, (char *) NilString, (char *) NilString,
- (char *) NilString );
-
- // • Set up new palette and attach it to our window
-
- InitPalette();
-
- // • Get position of center of window
-
- FindOrigin();
- }
-
- // • ------------------ Prepare Menus -------------------------------------
-
- void
- SetUpMenus( void )
- // •
- // • Set up the application menus using resources.
- {
- gMenuBar = GetNewMBar( kMBarID );
- SetMenuBar( gMenuBar );
-
- // • List desk accesories in Apple menu.
-
- AddResMenu( GetMHandle( kAppleID ), 'DRVR' );
-
- DrawMenuBar();
- }
-
- // • ------------------ Prepare Palettes ----------------------------------
-
- void
- InitPalette( void )
- // •
- // • Used to initialize color palette to be used
- // • for our window and off-screen GWorlds.
- {
- gCTable = GetCTable( kGrayCTableID );
- DetachResource( gCTable );
- (*gCTable)->ctFlags |= 0x4000; // • Speeds up later CopyBits calls
- gPalette = NewPalette( kNumColors, gCTable, pmTolerant+pmExplicit, 0 );
- if (gPalette == NullHandle)
- ErrorHandler( kNoMemoryMsg, (char *) NilString, (char *) NilString,
- (char *) NilString );
- NSetPalette( (WindowPtr) gMainWindow, gPalette, false );
- ActivatePalette( (WindowPtr) gMainWindow );
- ResetForeAndBackColors();
- }
-
- // • ------------------ Update Display Window Palette ---------------------
-
- void
- UpdateWindowColors( void )
- // •
- // • Sets window gray levels in palette.
- {
- RGBColor c;
-
- c.red = c.green = c.blue = gSettings.bkgndGray * 256;
- SetEntryColor( gPalette, kPalBkgnd, &c );
- SetEntryUsage( gPalette, kPalBkgnd, pmTolerant+pmExplicit, 0 );
- c.red = c.green = c.blue = gSettings.targetGray * 256;
- SetEntryColor( gPalette, kPalTarget, &c );
- SetEntryUsage( gPalette, kPalTarget, pmTolerant+pmExplicit, 0 );
- Palette2CTab( gPalette, gCTable );
-
- // • Reset window palette
-
- NSetPalette( (WindowPtr) gMainWindow, gPalette, true );
- ActivatePalette( (WindowPtr) gMainWindow );
- ResetForeAndBackColors();
- }
-